package com.drore.logapp.utils;

import android.text.TextUtils;

/**
 * Created by liub
 * time 2018/5/15
 */

public class StringUtils {
    /**
     * 字符串是否为空或null
     *
     * @param str
     * @return
     */
    public static boolean isNull(String str) {
        if (TextUtils.isEmpty(str) || "null".equals(str))
            return true;
        return false;
    }

    /**
     * 字符串是否为空或null
     *
     * @param str
     * @return
     */
    public static boolean isNull(Object str) {
        if ( null == str|| TextUtils.isEmpty(str.toString()) || "null".equals(str) || "".equals(str) )
            return true;
        return false;
    }

    /**
     * 字符串是否符合要求
     *
     * @param str   字符串
     * @param mlong 长度
     * @return
     */
    public static boolean isRequire(String str, int mlong) {
        if (TextUtils.isEmpty(str) || "null".equals(str) || str.length() != mlong)
            return false;
        return true;
    }
    /**
     * @author lb
     * @desc 1111-->1,111
     * @time 2018/5/30 11:26
     */
    public static String getSymbolString(String numStr, String mark, int num) {
        String newStr = "";
        int newLength = numStr.length();
        if (numStr.length() <= 0) {
            System.err.println("字符串为空！");
            return newStr;
        }
        while (newLength > num) {
            newStr = mark + numStr.substring(newLength - num, newLength) + newStr;
            newLength -= num;
        }
        newStr = numStr.substring(0, newLength) + newStr;
        return newStr;
    }
}
